#!/bin/bash

if [ ! -n "$1" ] ;then
    echo "使用格式：./publish.sh '提交内容'"
    exit 2
fi

echo '1. git checkout master'
git checkout master

echo '2. git add && git commit'
git add .
git commit -m $1

echo '3. git pull origin master'
git pull origin master

echo '4. git push origin master'
git push origin master

echo '5. gitbook build'
gitbook build

echo '6. git checkout pages'
git checkout pages

echo '7. 复制_book目录下文件到pages分支根目录'
cp -r _book/* .

echo '8. git status'
git status

echo '9. git add && git commit'

git add .
git commit -m $1

echo '10. git pull origin pages'
git pull origin pages

echo '11. git push origin pages'
git push origin pages

echo '12. 完成'
